<%-- 
    Document   : nuevoNivelUsuario
    Created on : 26-ago-2012, 17:50:32
    Author     : ADMIN
--%>

<%@page import="Entities.Nivelusuario"%>
<%@page import="java.util.Iterator"%>
<%@page import="javax.persistence.Query"%>
<%@page import="javax.persistence.Persistence"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form id="form1" name="form1" method="post" action="Sevlet/nuevoUsuario">
            <table width="288" border="0">
                <tr>
                <td colspan="2">INGRESAR NUEVO USUARIO</td>
                </tr>
                <tr>
                <td width="92">Nombre:</td>
                <td width="152"><label for="txtnombre"></label>
                <input type="text" name="txtnombre" id="txtnombre" /></td>
                </tr>
                <tr>
                <td>Apellido:</td>
                <td><input type="text" name="txtapellido" id="txtapellido" /></td>
                </tr>
                <tr>
                <td>Usuario:</td>
                <td><input type="text" name="txtusuario" id="txtusuario" /></td>
                </tr>
                <tr>
                <td>Contraseña:</td>
                <td><input type="text" name="txtpass" id="txtpass" /></td>
                </tr>
                <tr>
                <td>Nivel</td>
                <td><label for="cbnivel"></label>
                    
                        <%
                        
                        EntityManagerFactory emf=Persistence.createEntityManagerFactory("PU");
                        EntityManager em=emf.createEntityManager();
                        Query result = em.createNamedQuery("Nivelusuario.findAll");
                        String nivel;
                        int nivelid;
                            java.util.List nivelUsList = result.getResultList();
                            Iterator itr=nivelUsList.iterator();
                            out.println("<select name='cbnivel' id='cbnivel'>");
                            while(itr.hasNext())
                            {
                                Nivelusuario nus=(Nivelusuario)itr.next();
                                nivel=nus.getNivel();
                                nivelid=nus.getIdnivel();
                                out.println("<option value="+nivelid+">"+nivel+"</option>");
                            }

                    out.println("</select></td>");
                        
                        
                        %>
                        
                    

                </tr>
                <tr>
                <td><input type="submit" name="btnok" id="btnok" value="Aceptar" /></td>
                <td><input type="reset" name="btnno" id="btnno" value="Cancelar" /></td>
                </tr>
            </table>
            </form>
    </body>
</html>
